package com.fy.tt.action;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.fy.basejar.tool.ActionToolBase;
import com.fy.toolhelper.util.RequestUtils;
import com.fy.toolhelper.util.ResponseUtils;
import com.fy.tt.dao.*;
import com.fy.tt.dao.impl.*;
import com.fy.tt.entity.*;
import com.fy.tt.entity.query.*;
import com.fy.tt.entity.vo.*;
import com.fy.tt.executor.environment.MyMQ;
import com.fy.tt.executor.environment.PolicyWorker;
import com.fy.tt.executor.environment.threadPool.ThreadPoolGroup;
import com.fy.tt.parser.V3Lexer;
import com.fy.tt.parser.V3Parser;
import com.fy.tt.parser.Visitor;
import com.fy.tt.remote.service.CoreRemoteService;
import com.fy.tt.remote.service.IMessageToolRemoteService;
import com.fy.tt.remote.service.ITemplateRemoteService;
import com.fy.tt.remote.service.impl.CoreRemoteServiceImpl;
import com.fy.tt.remote.service.impl.MessageToolRemoteServiceImpl;
import com.fy.tt.remote.service.impl.TemplateRemoteServiceImpl;
import com.fy.tt.service.*;
import com.fy.tt.service.impl.*;
import com.fy.tt.util.JedisUtil;
import com.fy.tt.util.JsonUtils;
import com.fy.tt.util.R;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.TokenSource;
import org.antlr.v4.runtime.tree.ParseTree;
import org.apache.commons.fileupload.FileItem;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.concurrent.*;

/**
 * 工具模板
 * 注意: 建议使用alibaba的FastJson进行json解析. PS: 默认在lib包下了(lib存放各种非环境提供的依赖包).
 * 此项目结构中包除了工具主类(即这个类)不是都必须要的, 根据自己的工具业务增减.
 */
public class TemplateTool extends ActionToolBase {


	/* 词汇表：
	 * 查询最近添加词汇动态
	 * */
	@Action
	public Map<String,Object> getLastSaveWord(HttpServletRequest request) throws Exception{
		WordService wordService = getBean(WordService.class);
		List<WordVo> words = wordService.getLastSaveWord();
		return ResponseUtils.asResultAndMsg(words,"查询最近添加词汇动态成功");
	}

	/* 语义表：
	 * 查询最近添加语义动态
	 * */
	@Action
	public Map<String,Object> getLastSaveSemantic(HttpServletRequest request) throws Exception{
		SemanticService semanticService = getBean(SemanticService.class);
		List<SemanticVo> semantics = semanticService.getLastSaveSemantic();
		return ResponseUtils.asResultAndMsg(semantics,"查询最近添加语义动态成功");
	}

	/* 句型表：
	 * 查询最近添加句型动态
	 * */
	@Action
	public Map<String,Object> getLastSaveSentence(HttpServletRequest request) throws Exception{
		SentenceService sentenceService = getBean(SentenceService.class);
		List<SentenceVo> sentences = sentenceService.getLastSaveSentence();
		return ResponseUtils.asResultAndMsg(sentences,"查询最近添加句型动态成功");
	}

	/* 剧本表：
	 * 查询最近添加剧本动态
	 * */
	@Action
	public Map<String,Object> getLastSaveScript(HttpServletRequest request) throws Exception{
		ScriptService scriptService = getBean(ScriptService.class);
		List<ScriptVo> scripts = scriptService.getLastSaveScript();
		return ResponseUtils.asResultAndMsg(scripts,"查询最近添加剧本动态成功");
	}

	/* 剧本表：
	 * 查询最近运行剧本动态
	 * */
	@Action
	public Map<String,Object> getLastRunScript(HttpServletRequest request) throws Exception{
		ScriptService scriptService = getBean(ScriptService.class);
		List<ScriptVo> scripts = scriptService.getLastRunScript();
		return ResponseUtils.asResultAndMsg(scripts,"查询最近添加剧本动态成功");
	}

	/*
	 * 更新解释器
	 * */
	@Action
	public Map<String,Object> updateExecutor(HttpServletRequest request) throws Exception{
		String outPutPath = "G:\\test3\\languageExecutor\\src\\com\\language\\parser\\Word.cla";
		ParserRelatedFile parserRelatedFile = getBean(ParserRelatedFile.class);
		parserRelatedFile.updateExecutor(outPutPath);
		return ResponseUtils.asResultAndMsg(true,"generate g4、cla success");
	}

	/*
	* 物理路径测试
	* */
	@Action
	public Map<String,Object> t(HttpServletRequest request) throws Exception{
		String realPath = request.getSession().getServletContext().getRealPath("");
		System.out.println(realPath);
		String[] split = realPath.split("out" );
		for (String path : split){
			realPath = path;
			break;
		}
		return ResponseUtils.asResultAndMsg(realPath,"generate g4、cla success");
	}

	/* 词汇表：
	* 查询所有词汇
	* */
	@Action
	@Deprecated
	public Map<String,Object> getAllWords(HttpServletRequest request) throws Exception{
		String realPath = request.getServletContext().getRealPath("/temp");
		System.out.println(realPath);
		WordService wordService = getBean(WordService.class);
		List<WordVo> words = wordService.getAllWords();
		return ResponseUtils.asResultAndMsg(words,"查询所有词汇成功");
	}

	/*
	 * 查询已开发词汇的词汇语义
	 * */
	@Action
	public Map<String,Object> getWordSemantic(HttpServletRequest request) throws Exception{
		WordService wordService = getBean(WordService.class);
		List<WordAndSemanticVo> words = wordService.getWordSemantic();
		return ResponseUtils.asResultAndMsg(words,"查询已开发词汇的词汇语义成功");
	}

	/*
	 * 查询已开发词汇的词汇语义(分页)
	 * */
	@Action
	public Map<String,Object> getConditionPageWordSemanticDeveloped(HttpServletRequest request) throws Exception{
		JSONObject jsonString = JSONObject.parseObject(RequestUtils.getStringParameter(request, "semanticQuery"));
		SemanticQuery semanticQuery = JsonUtils.getJavaObject(jsonString, SemanticQuery.class);
		JSONObject pageInfo = JSONObject.parseObject(RequestUtils.getStringParameter(request, "pageInfo")) ;
		WordService wordService = getBean(WordService.class);
		Integer pageSize = (Integer) pageInfo.get("pageSize");
		Integer currentPage= (Integer) pageInfo.get("currentPage");
		List<WordAndSemanticVo> wordSemantics = wordService.getConditionPageWordSemanticDeveloped(semanticQuery,pageSize,currentPage);

		return ResponseUtils.asResultAndMsg(wordSemantics,"查询词汇、词汇语义成功");
	}

	/*
	 * 查询词汇、词汇语义
	 * */
	@Action
	public Map<String,Object> getAllWordSemantic(HttpServletRequest request) throws Exception{
		WordService wordService = getBean(WordService.class);
		List<WordAndSemanticVo> words = wordService.getAllWordSemantic();
		return ResponseUtils.asResultAndMsg(words,"查询词汇、词汇语义成功");
	}

	/*
	 * 多条件分页查询词汇、词汇语义
	 * */
	@Action
	public Map<String,Object> getConditionPageAllWordSemantic(HttpServletRequest request) throws Exception{
		JSONObject jsonString = JSONObject.parseObject(RequestUtils.getStringParameter(request, "semanticQuery"));
		SemanticQuery semanticQuery = JsonUtils.getJavaObject(jsonString, SemanticQuery.class);
		JSONObject pageInfo = JSONObject.parseObject(RequestUtils.getStringParameter(request, "pageInfo")) ;
		WordService wordService = getBean(WordService.class);
		Integer pageSize = (Integer) pageInfo.get("pageSize");
		Integer currentPage= (Integer) pageInfo.get("currentPage");
		List<WordAndSemanticVo> wordSemantics = wordService.getConditionPageAllWordSemantic(semanticQuery,pageSize,currentPage);
		return ResponseUtils.asResultAndMsg(wordSemantics,"查询词汇、词汇语义成功");
	}


	/*
	* 多条件查询总数
	* */
	@Action
	public Map<String,Object> getTotalWord(HttpServletRequest request) throws Exception{
		JSONObject jsonString = JSONObject.parseObject(RequestUtils.getStringParameter(request, "wordQuery"));
		WordQuery wordQuery = JsonUtils.getJavaObject(jsonString, WordQuery.class);
		WordService wordService = getBean(WordService.class);
		int count = wordService.getTotalWord(wordQuery);
		return ResponseUtils.asResultAndMsg(count,"查询词汇总数成功");
	}

	/**
	 * 添加新词汇
	 * */
	@Action
	public Map<String,Object> addWord(HttpServletRequest request) throws Exception{
		JSONObject jsonParam = JSONObject.parseObject(RequestUtils.getStringParameter(request, "newWord")) ;
		Word word = JsonUtils.getJavaObject(jsonParam, Word.class);
		word.setIsTypeIn(0L);
		word.setIsRange(0L);
		word.setStatus(0L);
		word.setUpdateTime(new Date());
		WordService wordService = getBean(WordService.class);
		int i = wordService.addWord(word);
		return ResponseUtils.asResultAndMsg(i,"添加词汇成功");
	}

	/**
	 * 删除词汇
	 * */
	@Action
	public Map<String,Object> deleteWord(HttpServletRequest request) throws Exception{
		Integer wordId = RequestUtils.getIntegerParameter(request, "wordId");
		WordService wordService = getBean(WordService.class);
		int i = wordService.deleteWord(wordId);
		return ResponseUtils.asResultAndMsg(i,"删除词汇成功");
	}

	/**
	 * 修改词汇
	 * */
	@Action
	public Map<String,Object> updateWord(HttpServletRequest request) throws Exception{
		JSONObject jsonParam = JSONObject.parseObject(RequestUtils.getStringParameter(request, "updateWord")) ;
		Word word = JsonUtils.getJavaObject(jsonParam, Word.class);
		word.setUpdateTime(new Date());
		WordService wordService = getBean(WordService.class);
		int i = wordService.updateWord(word);
		return ResponseUtils.asResultAndMsg(i,"修改词汇成功");
	}

	/*
	 * 分页查询
	 * */
	@Action
	@Deprecated
	public Map<String,Object> getPageWords(HttpServletRequest request) throws Exception{
		Integer pageSize = RequestUtils.getIntegerParameter(request, "pageSize");
		Integer currentPage = RequestUtils.getIntegerParameter(request, "currentPage");
		WordService wordService = getBean(WordService.class);
		List<Word> words = wordService.getPageWords(pageSize, currentPage);
		return ResponseUtils.asResultAndMsg(words,"分页查询成功");
	}

	/*
	 * 多条件分页查询
	 * */
	@Action
	public Map<String,Object> getConditionPageWords(HttpServletRequest request) throws Exception{
        JSONObject jsonString = JSONObject.parseObject(RequestUtils.getStringParameter(request, "wordQuery"));
        WordQuery wordQuery = JsonUtils.getJavaObject(jsonString, WordQuery.class);
        JSONObject pageInfo = JSONObject.parseObject(RequestUtils.getStringParameter(request, "pageInfo")) ;
		WordService wordService = getBean(WordService.class);
        Integer pageSize = (Integer) pageInfo.get("pageSize");
        Integer currentPage= (Integer) pageInfo.get("currentPage");
        List<WordVo> words = wordService.getConditionPageWords(wordQuery,pageSize,currentPage);


//		// TODO: 2021/12/30  测试部署后根据bandName 获取帮区信息
//		CoreRemoteService coreRemoteService = getBean(CoreRemoteService.class);
//		JSONObject jsonObject = coreRemoteService.getChatroomByChatroomName("2019级梁子豪论文消息板");
//		JSONArray rows = jsonObject.getJSONArray("rows");
//		System.out.println(rows);
//		String chatroomID = (String) rows.getJSONObject(0).get("chatroomID");
//		System.out.println("chatroomID = " + chatroomID);
		return ResponseUtils.asResultAndMsg(words,"多条件分页查询成功");
	}
//---------------------------------------------------------------------------
	/*
	* 词汇语义表：
	* 查看词汇语义
	* */
	@Action
	public Map<String,Object> getSemantic(HttpServletRequest request) throws Exception{
		SemanticService semanticService = getBean(SemanticService.class);
		Integer wordId = RequestUtils.getIntegerParameter(request, "wordId");
		Semantic semantic = semanticService.getSemantic(wordId);
		return ResponseUtils.asResultAndMsg(semantic,"查询词汇语义成功");
	}


	@Action
	public Map<String,Object> getTotalSemantic(HttpServletRequest request) throws Exception{
		JSONObject jsonString = JSONObject.parseObject(RequestUtils.getStringParameter(request, "semanticQuery"));
		SemanticQuery semanticQuery = JsonUtils.getJavaObject(jsonString, SemanticQuery.class);
		SemanticService semanticService = getBean(SemanticService.class);
		int count = semanticService.getTotalSemantic(semanticQuery);
		return ResponseUtils.asResultAndMsg(count,"查询词汇语义总数成功");
	}

	@Action
	public Map<String,Object> getTotalSemanticDeveloped(HttpServletRequest request) throws Exception{
		JSONObject jsonString = JSONObject.parseObject(RequestUtils.getStringParameter(request, "semanticQuery"));
		SemanticQuery semanticQuery = JsonUtils.getJavaObject(jsonString, SemanticQuery.class);
		SemanticService semanticService = getBean(SemanticService.class);
		int count = semanticService.getTotalSemanticDeveloped(semanticQuery);
		return ResponseUtils.asResultAndMsg(count,"查询词汇语义总数成功");
	}

	/*
	* 添加词汇语义
	* */
	@Action
	public Map<String,Object> addSemantic(HttpServletRequest request) throws Exception{
		JSONObject jsonParam = JSONObject.parseObject(RequestUtils.getStringParameter(request, "newSemantic")) ;
		Semantic semantic = JsonUtils.getJavaObject(jsonParam, Semantic.class);
		semantic.setUpdateTime(new Date());
		SemanticService semanticService = getBean(SemanticService.class);
		int i = semanticService.addSemantic(semantic);
		ParserService parserService = getBean(ParserService.class);
		Long bandObjId = semantic.getBandObjId();
		Parser parser =  parserService.getParserByObjId(bandObjId);
		parser.setWordsUpdateTime(new Date());
		parser.setParseUpdateTime(new Date());
		parserService.updateParser(parser);
		return ResponseUtils.asResultAndMsg(i,"添加词汇语义成功 并且更新了解释器 ");
	}

	/*
	* 删除词汇语义
	* */
	@Action
	public Map<String,Object> deleteSemantic(HttpServletRequest request) throws Exception{
		Integer semanticId = RequestUtils.getIntegerParameter(request, "semanticId");
		SemanticService semanticService = getBean(SemanticService.class);
		int i = semanticService.deleteSemantic(semanticId);
		return ResponseUtils.asResultAndMsg(i,"删除词汇语义成功");
	}

	/*
	* 修改词汇语义
	* */
	@Action
	public Map<String,Object> updateSemantic(HttpServletRequest request) throws Exception{
		JSONObject jsonParam = JSONObject.parseObject(RequestUtils.getStringParameter(request, "updateSemantic")) ;
		System.out.println(jsonParam);
		Semantic semantic = JsonUtils.getJavaObject(jsonParam, Semantic.class);
		semantic.setUpdateTime( new Date());
		ArrayList<Long> developerIds = JsonUtils.string2Array(jsonParam.getString("developerIds"));
		semantic.setDeveloperIds(developerIds);
		SemanticService semanticService = getBean(SemanticService.class);
		int i = semanticService.updateSemantic(semantic);
		return ResponseUtils.asResultAndMsg(i,"修改词汇语义成功");
	}


//------------------------------------------------------------------------------------------------------
	/*
	 * 剧本表：
	 * 查看所有剧本
	 * */
	@Action
	public Map<String,Object> getAllScripts(HttpServletRequest request) throws Exception{
		ScriptService scriptService = getBean(ScriptService.class);
		List<ScriptVo> scripts = scriptService.getAllScripts();
		return ResponseUtils.asResultAndMsg(scripts,"查看所有剧本成功");
	}

	/*
	 * 多条件查询总数
	 * */
	@Action
	@Deprecated
	public Map<String,Object> getTotalScript(HttpServletRequest request) throws Exception{
		JSONObject jsonString = JSONObject.parseObject(RequestUtils.getStringParameter(request, "scriptQuery"));
		ScriptQuery scriptQuery = JsonUtils.getJavaObject(jsonString, ScriptQuery.class);
		ScriptService scriptService = getBean(ScriptService.class);
		int count = scriptService.getTotalScript(scriptQuery);
		return ResponseUtils.asResultAndMsg(count,"查询剧本总数成功");
	}

	/*
	 * 添加剧本
	 * */
	@Action
	public Map<String,Object> addScript(HttpServletRequest request) throws Exception{
		JSONObject addScript = JSONObject.parseObject(RequestUtils.getStringParameter(request, "addScript"));
		Script script = JsonUtils.getJavaObject(addScript, Script.class);
		script.setSaveTime(new Date());
		script.setLastTime(new Date());
		script.setType(0L);
		ArrayList<Long> saverIds = JsonUtils.string2Array(addScript.getString("saverIds"));
		script.setSaverIds(saverIds);
		// 需用通过解释器解析获取相关词汇id列表，暂时为假数据
		ArrayList<Long> relatedWords = JsonUtils.string2Array("[3]");
		script.setRelatedWords(relatedWords);
		ScriptService scriptService = getBean(ScriptService.class);
		int i = scriptService.addScript(script);
		return ResponseUtils.asResultAndMsg(i,"添加剧本成功");
	}

	/*
	 * 删除剧本
	 * */
	@Action
	public Map<String,Object> deleteScript(HttpServletRequest request) throws Exception{
		Integer scriptId = RequestUtils.getIntegerParameter(request, "scriptId");
		ScriptService scriptService = getBean(ScriptService.class);
		int i = scriptService.deleteScript(scriptId);
		return ResponseUtils.asResultAndMsg(i,"删除剧本成功");
	}

	/*
	 * 修改剧本
	 * */
	@Action
	public Map<String,Object> updateScript(HttpServletRequest request) throws Exception{
		JSONObject jsonParam = JSONObject.parseObject(RequestUtils.getStringParameter(request, "updateScript")) ;
		Script script = JsonUtils.getJavaObject(jsonParam, Script.class);
		script.setSaveTime(new Date());
		ScriptService scriptService = getBean(ScriptService.class);
		int i = scriptService.updateScript(script);
		return ResponseUtils.asResultAndMsg(i,"修改剧本成功");
	}

	/*
	 * 分页查询
	 * */
	@Action
	@Deprecated
	public Map<String,Object> getPageScripts(HttpServletRequest request) throws Exception{
		Integer pageSize = RequestUtils.getIntegerParameter(request, "pageSize");
		Integer currentPage = RequestUtils.getIntegerParameter(request, "currentPage");
		ScriptService scriptService = getBean(ScriptService.class);
		List<Script> scripts = scriptService.getPageScripts(pageSize, currentPage);
		return ResponseUtils.asResultAndMsg(scripts,"分页查询成功");
	}

	/*
	 * 多条件分页查询
	 * */
	@Action
	public Map<String,Object> getConditionPageScripts(HttpServletRequest request) throws Exception{
		JSONObject jsonString = JSONObject.parseObject(RequestUtils.getStringParameter(request, "scriptQuery"));
		ScriptQuery scriptQuery = JsonUtils.getJavaObject(jsonString, ScriptQuery.class);
		JSONObject pageInfo = JSONObject.parseObject(RequestUtils.getStringParameter(request, "pageInfo")) ;

		ScriptService scriptService = getBean(ScriptService.class);
		Integer pageSize = (Integer) pageInfo.get("pageSize");
		Integer currentPage= (Integer) pageInfo.get("currentPage");
		List<ScriptVo> scripts = scriptService.getConditionPageScripts(scriptQuery,pageSize,currentPage);
		return ResponseUtils.asResultAndMsg(scripts,"多条件分页查询成功");
	}

	/*
	*  获得相关词汇语义
	* */
	@Action
	public Map<String,Object> getRelatedSemantics(HttpServletRequest request) throws Exception{
		Integer scriptId = RequestUtils.getIntegerParameter(request, "scriptId");
		ScriptService scriptService = getBean(ScriptService.class);
		List<Semantic> semantics = scriptService.getRelatedSemantic(scriptId);
		return ResponseUtils.asResultAndMsg(semantics,"多条件分页查询成功");
	}

	/*
	*  试运行剧本
	*
	* */
	@Action
	public Map<String,Object> runScript(HttpServletRequest request) throws Exception{
		String scripts = RequestUtils.getStringParameter(request, "scripts");
		List<RunScriptVo> runScriptVoList = JSON.parseObject(scripts, new TypeReference<List<RunScriptVo>>(){});
		Integer bandObjId = RequestUtils.getIntegerParameter(request, "bandObjId");
		ScriptService scriptService = getBean(ScriptService.class);
		R r = scriptService.runScript(runScriptVoList, bandObjId);
		return ResponseUtils.asResultAndMsg(r,"试运行剧本成功");
	}


	public static Map<String, List<Future>> scriptRunningStatus = new Hashtable<>();

	@Action
	public Map<String,Object> runOneScript(HttpServletRequest request) throws Exception{

		String script = RequestUtils.getStringParameter(request, "script");
		String id = RequestUtils.getStringParameter(request, "id");

		CharStream input = CharStreams.fromString(script);

		//词法分析
		V3Lexer lexer = new V3Lexer(input);
		CommonTokenStream tokens = new CommonTokenStream((TokenSource) lexer);

		//语法分析
		V3Parser parser = new V3Parser(tokens);
		ParseTree tree = parser.script();

		Visitor myVisitor = new Visitor();
		List<Future> tasks = myVisitor.visit(tree);
		//scriptRunningStatus.put(id,tasks);
		return ResponseUtils.asResultAndMsg(R.ok(),"运行剧本成功");
	}

	@Action
	public Map<String,Object> cancelOneScript(HttpServletRequest request) throws Exception{
		String id = RequestUtils.getStringParameter(request, "id");
		List<Future> tasks = scriptRunningStatus.get(id);
		for(Future task: tasks){
			System.out.println("停用剧本。。。"+task);
			task.cancel(true);
		}
		return ResponseUtils.asResultAndMsg(R.ok(),"停用剧本成功");
	}

	/*
	*  调试剧本
	* */
	@Action
	public Map<String,Object> deBugScript(HttpServletRequest request) throws Exception{
		String scripts = RequestUtils.getStringParameter(request, "scripts");
		List<RunScriptVo> runScriptVoList = JSON.parseObject(scripts, new TypeReference<List<RunScriptVo>>(){});
		Integer bandObjId = RequestUtils.getIntegerParameter(request, "bandObjId");
		ScriptService scriptService = getBean(ScriptService.class);
		R r = scriptService.deBugScript(runScriptVoList, bandObjId);
		return ResponseUtils.asResultAndMsg(r,"调试剧本成功");
	}

	/*
	*  获得语法树
	* */
	@Action
	public Map<String,Object> showAST(HttpServletRequest request) throws Exception{
		String scripts = RequestUtils.getStringParameter(request, "scripts");
		List<RunScriptVo> runScriptVoList = JSON.parseObject(scripts, new TypeReference<List<RunScriptVo>>(){});
		Integer bandObjId = RequestUtils.getIntegerParameter(request, "bandObjId");
		ScriptService scriptService = getBean(ScriptService.class);
		R showASTResult = scriptService.showAST(runScriptVoList, bandObjId);
		return ResponseUtils.asResultAndMsg(showASTResult,"解析剧本成功");
	}
// ---------------------------------------------------------------------------------------------------
//public static Map<String, List<Future>> scriptRunningStatus = new Hashtable<>();

	@Action
	public Map<String,Object> runScriptTest(HttpServletRequest request) throws Exception{
		String scripts = RequestUtils.getStringParameter(request, "scripts");
		Integer scriptId = RequestUtils.getIntegerParameter(request, "scriptId");
		List<RunScriptVo> runScriptVoList = JSON.parseObject(scripts, new TypeReference<List<RunScriptVo>>(){});
		Integer bandObjId = RequestUtils.getIntegerParameter(request, "bandObjId");
		ScriptService scriptService = getBean(ScriptService.class);
		R r = scriptService.runScriptTest(runScriptVoList, bandObjId, scriptId);
		return ResponseUtils.asResultAndMsg(r,"试运行剧本成功");
	}

	@Action
	public Map<String,Object> cancelScriptTest(HttpServletRequest request) throws Exception{
		String scriptId = RequestUtils.getStringParameter(request, "scriptId");
		if(scriptRunningStatus.containsKey(scriptId)){
			List<Future> tasks = scriptRunningStatus.get(scriptId);
			for(Future task: tasks){
				System.out.println("停用剧本。。。"+task);
				task.cancel(true);
			}
			return ResponseUtils.asResultAndMsg(R.ok(),"停用剧本成功");
		}
		return ResponseUtils.asResultAndMsg(R.ok(),"当前剧本已处于停用状态");
	}

	@Action
	public Map<String,Object> deBugScriptTest(HttpServletRequest request) throws Exception{
		String scripts = RequestUtils.getStringParameter(request, "scripts");
		Integer scriptId = RequestUtils.getIntegerParameter(request, "scriptId");
		List<RunScriptVo> runScriptVoList = JSON.parseObject(scripts, new TypeReference<List<RunScriptVo>>(){});
		Integer bandObjId = RequestUtils.getIntegerParameter(request, "bandObjId");
		ScriptService scriptService = getBean(ScriptService.class);
		R r = scriptService.deBugScriptTest(runScriptVoList, bandObjId, scriptId);
		return ResponseUtils.asResultAndMsg(r,"调试剧本成功");
	}

	@Action
	public Map<String,Object> showASTTest(HttpServletRequest request) throws Exception{
		String scripts = RequestUtils.getStringParameter(request, "scripts");
		List<RunScriptVo> runScriptVoList = JSON.parseObject(scripts, new TypeReference<List<RunScriptVo>>(){});
		Integer bandObjId = RequestUtils.getIntegerParameter(request, "bandObjId");
		ScriptService scriptService = getBean(ScriptService.class);
		R showASTResult = scriptService.showASTTest(runScriptVoList, bandObjId);
		return ResponseUtils.asResultAndMsg(showASTResult,"解析剧本成功");
	}
// ---------------------------------------------------------------------------------------------------

	/*
	*  分享剧本（push）
	* */
	@Action
	public Map<String,Object> pushScript(HttpServletRequest request) throws Exception{
		Integer scriptId = RequestUtils.getIntegerParameter(request, "scriptId");
		Integer bandObjId = RequestUtils.getIntegerParameter(request, "bandObjId");
		ScriptService scriptService = getBean(ScriptService.class);
		R pushScriptResult = scriptService.pushScript(scriptId, bandObjId);
		return ResponseUtils.asResultAndMsg(pushScriptResult,"分享剧本成功");
	}

	/*
	*  应用剧本（pull）
	* */


//------------------------------------------------------------------------------------------------------

	/* 句型表：
	 * 查询所有句型
	 * */
	@Action
	public Map<String,Object> getAllSentences(HttpServletRequest request) throws Exception{
		SentenceService sentenceService = getBean(SentenceService.class);
		List<SentenceVo> sentences = sentenceService.getAllSentences();
		return ResponseUtils.asResultAndMsg(sentences,"查询所有句型成功");
	}

	/*
	 * 多条件查询总数
	 * */
	@Action
	@Deprecated
	public Map<String,Object> getTotalSentence(HttpServletRequest request) throws Exception{
		JSONObject jsonString = JSONObject.parseObject(RequestUtils.getStringParameter(request, "sentenceQuery"));
		SentenceQuery sentenceQuery = JsonUtils.getJavaObject(jsonString, SentenceQuery.class);
		SentenceService sentenceService = getBean(SentenceService.class);
		int count = sentenceService.getTotalSentence(sentenceQuery);
		return ResponseUtils.asResultAndMsg(count,"查询句型总数成功");
	}

	/**
	 * 添加新句型
	 * */
	@Action
	public Map<String,Object> addSentence(HttpServletRequest request) throws Exception{
		JSONObject jsonParam = JSONObject.parseObject(RequestUtils.getStringParameter(request, "newSentence")) ;
		Sentence sentence = JsonUtils.getJavaObject(jsonParam, Sentence.class);
		SentenceService sentenceService = getBean(SentenceService.class);
		// 句型暂时不考虑新增，默认已开发完成，仅供查看
		sentence.setIsTypeIn(1L);
		sentence.setStatus(1L);
		sentence.setUpdateTime( new Date());
		int i = sentenceService.addSentence(sentence);
		return ResponseUtils.asResultAndMsg(i,"添加句型成功");
	}

	/**
	 * 删除句型
	 * */
	@Action
	public Map<String,Object> deleteSentence(HttpServletRequest request) throws Exception{
		Integer sentenceId = RequestUtils.getIntegerParameter(request, "sentenceId");
		SentenceService sentenceService = getBean(SentenceService.class);
		int i = sentenceService.deleteSentence(sentenceId);
		return ResponseUtils.asResultAndMsg(i,"删除句型成功");
	}

	/**
	 * 修改句型
	 * */
	@Action
	public Map<String,Object> updateSentence(HttpServletRequest request) throws Exception{
		JSONObject jsonParam = JSONObject.parseObject(RequestUtils.getStringParameter(request, "updateSentence")) ;
		Sentence sentence = JsonUtils.getJavaObject(jsonParam, Sentence.class);
		SentenceService sentenceService = getBean(SentenceService.class);
		sentence.setUpdateTime( new Date());
		int i = sentenceService.updateSentence(sentence);
		return ResponseUtils.asResultAndMsg(i,"修改句型成功");
	}

	/*
	 * 分页查询
	 * */
	@Action
	public Map<String,Object> getPageSentences(HttpServletRequest request) throws Exception{
		Integer pageSize = RequestUtils.getIntegerParameter(request, "pageSize");
		Integer currentPage = RequestUtils.getIntegerParameter(request, "currentPage");
		SentenceService sentenceService = getBean(SentenceService.class);
		List<Sentence> sentences = sentenceService.getPageSentences(pageSize, currentPage);
		return ResponseUtils.asResultAndMsg(sentences,"分页查询成功");
	}

	/*
	 * 多条件分页查询
	 * */
	@Action
	public Map<String,Object> getConditionPageSentences(HttpServletRequest request) throws Exception{
		System.out.println("getConditionPageSentences......");
		JSONObject jsonString = JSONObject.parseObject(RequestUtils.getStringParameter(request, "sentenceQuery"));
		SentenceQuery sentenceQuery = JsonUtils.getJavaObject(jsonString, SentenceQuery.class);
		JSONObject pageInfo = JSONObject.parseObject(RequestUtils.getStringParameter(request, "pageInfo")) ;

		SentenceService sentenceService = getBean(SentenceService.class);
		Integer pageSize = (Integer) pageInfo.get("pageSize");
		Integer currentPage= (Integer) pageInfo.get("currentPage");
		List<SentenceVo> sentences = sentenceService.getConditionPageSentences(sentenceQuery,pageSize,currentPage);
		return ResponseUtils.asResultAndMsg(sentences,"分页查询成功");
	}

//------------------------------------------------------------------------------------------------------

	/* 语境表：
	 * 查询所有语境
	 * */
	@Action
	public Map<String,Object> getAllEnvironments(HttpServletRequest request) throws Exception{
		EnvironmentService environmentService = getBean(EnvironmentService.class);
		List<Environment> environments = environmentService.getAllEnvironments();
		return ResponseUtils.asResultAndMsg(environments,"查询所有语境成功");
	}

	/**
	 * 添加新语境
	 * */
	@Action
	public Map<String,Object> addEnvironment(HttpServletRequest request) throws Exception{
		JSONObject jsonParam = JSONObject.parseObject(RequestUtils.getStringParameter(request, "newEnvironment")) ;
		Environment environment = JsonUtils.getJavaObject(jsonParam, Environment.class);
		EnvironmentService environmentService = getBean(EnvironmentService.class);
		int i = environmentService.addEnvironment(environment);
		return ResponseUtils.asResultAndMsg(i,"添加语境成功");
	}

	/**
	 * 删除语境
	 * */
	@Action
	public Map<String,Object> deleteEnvironment(HttpServletRequest request) throws Exception{
		Integer environmentId = RequestUtils.getIntegerParameter(request, "environmentId");
		EnvironmentService environmentService = getBean(EnvironmentService.class);
		int i = environmentService.deleteEnvironment(environmentId);
		return ResponseUtils.asResultAndMsg(i,"删除语境成功");
	}

	/**
	 * 修改语境
	 * */
	@Action
	public Map<String,Object> updateEnvironment(HttpServletRequest request) throws Exception{
		JSONObject jsonParam = JSONObject.parseObject(RequestUtils.getStringParameter(request, "updateEnvironment")) ;
		Environment environment = JsonUtils.getJavaObject(jsonParam, Environment.class);
		EnvironmentService environmentService = getBean(EnvironmentService.class);
		int i = environmentService.updateEnvironment(environment);
		return ResponseUtils.asResultAndMsg(i,"修改语境成功");
	}

	/*
	 * 分页查询
	 * */
	@Action
	public Map<String,Object> getPageEnvironments(HttpServletRequest request) throws Exception{
		Integer pageSize = RequestUtils.getIntegerParameter(request, "pageSize");
		Integer currentPage = RequestUtils.getIntegerParameter(request, "currentPage");
		EnvironmentService environmentService = getBean(EnvironmentService.class);
		List<Environment> environments = environmentService.getPageEnvironments(pageSize, currentPage);
		return ResponseUtils.asResultAndMsg(environments,"分页查询成功");
	}

	/*
	 * 多条件分页查询
	 * */
	@Action
	public Map<String,Object> getConditionPageEnvironments(HttpServletRequest request) throws Exception{
		System.out.println("getConditionPageEnvironments......");
		JSONObject jsonString = JSONObject.parseObject(RequestUtils.getStringParameter(request, "environmentQuery"));
		EnvironmentQuery environmentQuery = JsonUtils.getJavaObject(jsonString, EnvironmentQuery.class);
		JSONObject pageInfo = JSONObject.parseObject(RequestUtils.getStringParameter(request, "pageInfo")) ;

		EnvironmentService environmentService = getBean(EnvironmentService.class);
		Integer pageSize = (Integer) pageInfo.get("pageSize");
		Integer currentPage= (Integer) pageInfo.get("currentPage");
		List<Environment> environments = environmentService.getConditionPageEnvironments(environmentQuery,pageSize,currentPage);
		return ResponseUtils.asResultAndMsg(environments,"分页查询成功");
	}

	//----------------------------------------------------------------------------
	/* 解释器表：
	 * 查询所有解释器
	 * */
	@Action
	@Deprecated
	public Map<String,Object> getAllParsers(HttpServletRequest request) throws Exception{
		ParserService parserService = getBean(ParserService.class);
		List<Parser> parsers = parserService.getAllParsers();
		return ResponseUtils.asResultAndMsg(parsers,"查询所有解释器成功");
	}

	/**
	 * 添加新解释器
	 * */
	@Action
	public Map<String,Object> addParser(HttpServletRequest request) throws Exception{
		JSONObject jsonParam = JSONObject.parseObject(RequestUtils.getStringParameter(request, "newParser")) ;
		Parser parser = JsonUtils.getJavaObject(jsonParam, Parser.class);
		ParserService parserService = getBean(ParserService.class);
		int i = parserService.addParser(parser);
		return ResponseUtils.asResultAndMsg(i,"添加解释器成功");
	}

	/**
	 * 删除解释器
	 * */
	@Action
	public Map<String,Object> deleteParser(HttpServletRequest request) throws Exception{
		Integer parserId = RequestUtils.getIntegerParameter(request, "parserId");
		ParserService parserService = getBean(ParserService.class);
		int i = parserService.deleteParser(parserId);
		return ResponseUtils.asResultAndMsg(i,"删除解释器成功");
	}

	/**
	 * 修改解释器
	 * */
	@Action
	public Map<String,Object> updateParser(HttpServletRequest request) throws Exception{
		JSONObject jsonParam = JSONObject.parseObject(RequestUtils.getStringParameter(request, "updateParser")) ;
		Parser parser = JsonUtils.getJavaObject(jsonParam, Parser.class);
		ParserService parserService = getBean(ParserService.class);
		int i = parserService.updateParser(parser);
		return ResponseUtils.asResultAndMsg(i,"修改解释器成功");
	}

	/*
	 * 分页查询
	 * */
	@Action
	@Deprecated
	public Map<String,Object> getPageParsers(HttpServletRequest request) throws Exception{
		Integer pageSize = RequestUtils.getIntegerParameter(request, "pageSize");
		Integer currentPage = RequestUtils.getIntegerParameter(request, "currentPage");
		ParserService parserService = getBean(ParserService.class);
		List<Parser> parsers = parserService.getPageParsers(pageSize, currentPage);
		return ResponseUtils.asResultAndMsg(parsers,"分页查询成功");
	}

	/*
	 * 多条件分页查询
	 * */
	@Action
	public Map<String,Object> getConditionPageParsers(HttpServletRequest request) throws Exception{
		JSONObject jsonString = JSONObject.parseObject(RequestUtils.getStringParameter(request, "parserQuery"));
		ParserQuery parserQuery = JsonUtils.getJavaObject(jsonString, ParserQuery.class);
		JSONObject pageInfo = JSONObject.parseObject(RequestUtils.getStringParameter(request, "pageInfo")) ;

		ParserService parserService = getBean(ParserService.class);
		Integer pageSize = (Integer) pageInfo.get("pageSize");
		Integer currentPage= (Integer) pageInfo.get("currentPage");
		List<ParserVo> parsers = parserService.getConditionPageParsers(parserQuery,pageSize,currentPage);
		return ResponseUtils.asResultAndMsg(parsers,"多条件分页查询成功");
	}

	@Action
	public Map<String, Object> getOrganizationAndBands(HttpServletRequest request) throws Exception {
		String objId = "";
		try {
			objId = RequestUtils.getStringParameter(request, "objId");
		}catch (Exception e){
			return ResponseUtils.asResultAndMsg("参数名称异常", "参数名称异常");
		}
		AllEnvironmentService environmentService = getBean(AllEnvironmentService.class);
		Map<String, Object> organizationAndBands = environmentService.getOrganizationAndBands(Long.valueOf(objId));
		return ResponseUtils.asResultAndMsg(organizationAndBands, "返回用户所在机构与其所在所有帮区");
	}

	@Action
	public Map<String, Object> getAllEnvironment(HttpServletRequest request) throws Exception {
		String objId = "";
		String organizationId = "";
		String realObjId = "";
		try {
			objId = RequestUtils.getStringParameter(request, "objId");
			organizationId = RequestUtils.getStringParameter(request, "organizationId");
			realObjId = RequestUtils.getStringParameter(request, "realObjId");
		}catch (Exception e){
			return ResponseUtils.asResultAndMsg("参数名称异常", "参数名称异常");
		}
		AllEnvironmentService environmentService = getBean(AllEnvironmentService.class);
		HashMap<String, Object> result = new HashMap<>();
		result.put("organizationEnvironment", environmentService.getOrganizationEnvironment(Long.valueOf(organizationId)));
		result.put("bandEnvironment", environmentService.getBandEnvironment(Long.valueOf(objId),Long.valueOf(realObjId)));
		return ResponseUtils.asResultAndMsg(result, "返回（机构、帮区、剧本）语境成功");
	}

	@Action
	public Map<String, Object> doAction(HttpServletRequest request) throws Exception {
		return ResponseUtils.asResultAndMsg(true, "方法名称即Action名称, 根据onBeforeAct回调中如何获取Action值");
	}
	/**
	 * 对外提供调用的接口, 方法名称即Action名称, 根据onBeforeAct回调中如何获取Action值来传参.
	 */

	@Action
	public Map<String, Object> doSomeBussiness(HttpServletRequest
			/* RequestParameter 如果需要使得同时兼容有页面和无页面的调用接口可以使用这个, 
			 * 若是用RequestUtils获取参数, 下面的代码不用改 */ request) throws Exception {
		// 统一使用RequestUtils工具类获取参数
		String strParam = RequestUtils.getStringParameter(request, "strParam");
		Long longParam = RequestUtils.getLongParameter(request, "longParam");
		List<Long> longListParam = RequestUtils.getLongJsonArrayParameter(request, "longListParam");
		/* 其它的还有各种类型, 请开发者自己查看 */
		// 对于创建接口, 传入一个json对象的字符串解析, 也可以使用RequestUtils进行获取参数
		JSONObject jsonParam = JSONObject.parseObject(RequestUtils.getStringParameter(request, "jsonParam")) ;
		String someKey1 = jsonParam.getString("someKey");
		// 或
		String someKey2 = RequestUtils.getStringParameter(jsonParam, "someKey2");
		// 都可以.
		// 文档上传, 根据上传时表单中文档的key来获取, 没有key的暂时没有支持请自行实现
		FileItem fileItem = getUploadFile("fileKey");
		byte[] bytes = fileItem.get();
		// 所有的Bean都通过该静态方法获取. 由于是静态方法, 在Service实现类中也可以调用
		ITemplateService templateService = getBean(ITemplateService.class);
		// PS: 不过要使用工具类名称, 如TemplateTool.getBean, 如果不希望Service实现类耦合工具顶层类, 请使用ActionTool.getBean
		templateService.doSomeBussiness();
		// ResponseUtils规范了返回值格式(具体组合请自己查看), 方便前端统一处理
		return ResponseUtils.asResultAndMsg(true, "业务操作完成");
	};
	
	/**
	 * 返回值默认将该返回的对象处理为JSON对象.
	 *  如果有特殊需求, 使用resultHandler属性设置处理类即可, 如果返回值类型与可处理类型不一致会报错.
	 *还可以为Action设置别名(可以多个), 这样多个名称指向同一个Action处理接口就可以做到了, 注意不要和已有的重复即可, 否则报错.
	 */
	@Action(resultHandler = OtherResultHandler.class, aliases = {"aliasActionName"})
	public byte[] returnBytes(HttpServletRequest request) {
		return "".getBytes();
	};
	
	/**
	 * 获取暴露给前端的一些配置信息
	 */
	@Action
	public Map<String, Object> getConfigs() {
		// 建议如果需要向前端暴露一些后台的配置或运行环境信息时, 可以通过这样一个action接口来实现. 比如当前用户的具体信息等等.
		return new HashMap<String, Object>();
	};
	
	// 可以额外定义的环境变量
	private static final String GLB_KEY_OTHER_TOOL_ID = "GLB_KEY_OTHER_TOOL_ID";
	
//	@Override
//	protected void onLoadJsonConfig(GlobalContext context, JSONObject configParamJson) throws Exception {
//		/* 对应加载config.xml中的toolConfig的内容, 必须是JSON才会进入此方法 */
//		context.putGlobal(GLB_KEY_OTHER_TOOL_ID, configParamJson.getLong("otherToolID"));
//	}
	
	/* 这里是特别需求的类声明 */

	/**
	 * 以特殊返回值类型byte[]为例子, 实例ResultHandler的使用, 在{@link Action#resultHandler()}中表明该类字节码即可
	 */
	private final static class OtherResultHandler implements ResultHandler<byte[]/*这里是Action返回值的类型*/> {
		@Override
		public Object handle(HttpServletRequest request, 
				HttpServletResponse response, byte[] source) throws Exception {
			response.setContentType("image/jpeg");
			response.setHeader("Prgama", "No-cache");
			// ...
			response.getOutputStream().write(source);
			response.flushBuffer();
			return null;
		}
	}
	
	/* 这里是模拟Spring管理Bean提供的类实例管理的声明部分(没有依赖注入的处理, 所以不要把要用到的Bean声明为类成员变量) 
	 * 所有用到的Bean都要声明, 否则报错, 并且强烈建议forClass为接口, 注意保持声明方法的返回值类型与forClass一致*/
	
	@BeanDeclare(forClass = ITemplateService.class, scope = BeanScope.TEMPORY)
	private ITemplateService onDeclaringTemplateService() {
		// 这样做的好处是保留开发者自定义初始化的编程能力, 当然简单实例化情况下这样写也挺麻烦的
		return new TemplateServiceImpl();
	}
	
	@BeanDeclare(forClass = ITemplateDao.class, scope = BeanScope.TEMPORY)
	private ITemplateDao onDeclaringTemplateDao() throws Exception {
		return new TemplateDaoImpl();
	}
	
	@BeanDeclare(forClass = ITemplateRemoteService.class, scope = BeanScope.GLOBAL)
	private ITemplateRemoteService onDeclaringTemplateRemoteService() {
		return new TemplateRemoteServiceImpl() {
			@Override
			protected Long getToolID() throws Exception {
				return (Long) getGlobal(GLB_KEY_OTHER_TOOL_ID);
			}
		};
	}

	@BeanDeclare(forClass = CoreRemoteService.class, scope = BeanScope.GLOBAL)
	private CoreRemoteService onDeclaringCoreRemoteService() {
		return new CoreRemoteServiceImpl();
	}

	@BeanDeclare(forClass = AllEnvironmentService.class, scope = BeanScope.GLOBAL)
	private AllEnvironmentService onDeclaringAllEnvironmentService() {
		return new AllEnvironmentServiceImpl();
	}


	/*
	* 词汇表
	* */

	@BeanDeclare(forClass = WordService.class, scope = BeanScope.TEMPORY)
	private WordService onDeclaringWordService(){
		return new WordServiceImpl();
	}

	@BeanDeclare(forClass = WordDao.class, scope = BeanScope.TEMPORY)
	private WordDao onDeclaringWordDao() throws Exception {
		return new WordDaoImpl();
	}

	/*
	 * 词汇语义表
	 * */

	@BeanDeclare(forClass = SemanticService.class, scope = BeanScope.TEMPORY)
	private SemanticService onDeclaringSemanticService(){
		return new SemanticServiceImpl();
	}

	@BeanDeclare(forClass = SemanticDao.class, scope = BeanScope.TEMPORY)
	private SemanticDao onDeclaringSemanticDao() throws Exception {
		return new SemanticDaoImpl();
	}

	/*
	 * 剧本表
	 * */

	@BeanDeclare(forClass = ScriptService.class, scope = BeanScope.TEMPORY)
	private ScriptService onDeclaringScriptService(){
		return new ScriptServiceImpl();
	}

	@BeanDeclare(forClass = ScriptDao.class, scope = BeanScope.TEMPORY)
	private ScriptDao onDeclaringScriptDao() throws Exception {
		return new ScriptDaoImpl();
	}



	/*
	 * 句型表
	 * */
	@BeanDeclare(forClass = SentenceService.class, scope = BeanScope.TEMPORY)
	private SentenceService onDeclaringSentenceService(){
		return new SentenceServiceImpl();
	}

	@BeanDeclare(forClass = SentenceDao.class, scope = BeanScope.TEMPORY)
	private SentenceDao onDeclaringSentenceDao() throws Exception {
		return new SentenceDaoImpl();
	}

	/*
	 * 语境表
	 * */
	@BeanDeclare(forClass = EnvironmentService.class, scope = BeanScope.TEMPORY)
	private EnvironmentService onDeclaringEnvironmentService(){
		return new EnvironmentServiceImpl();
	}

	@BeanDeclare(forClass = EnvironmentDao.class, scope = BeanScope.TEMPORY)
	private EnvironmentDao onDeclaringEnvironmentDao() throws Exception {
		return new EnvironmentDaoImpl();
	}

	/*
	 * 解释器表
	 * */
	@BeanDeclare(forClass = ParserService.class, scope = BeanScope.TEMPORY)
	private ParserService onDeclaringParserService(){
		return new ParserServiceImpl();
	}

	@BeanDeclare(forClass = ParserDao.class, scope = BeanScope.TEMPORY)
	private ParserDao onDeclaringParserDao() throws Exception {
		return new ParserDaoImpl();
	}

	/*
	 * 解释生成文件
	 * */
	@BeanDeclare(forClass = ParserRelatedFile.class, scope = BeanScope.TEMPORY)
	private ParserRelatedFile onDeclaringParserRelatedFile(){
		return new ParserRelatedFileImpl();
	}


	/*
	 * 自定义线程池
	 * */
	@BeanDeclare(forClass = ThreadPoolExecutor.class, scope = BeanScope.GLOBAL)
	private ThreadPoolExecutor onDeclaringThreadPoolExecutor(){
		return new ThreadPoolExecutor(
				20,
				40,
				3,
				TimeUnit.MINUTES,
				new LinkedBlockingDeque<>(100),
				Executors.defaultThreadFactory(),
				new ThreadPoolExecutor.AbortPolicy()
				);
	}
	/*
	 * 自定义线程池组
	 * */
	@BeanDeclare(forClass = ThreadPoolGroup.class, scope = BeanScope.GLOBAL)
	private ThreadPoolGroup onDeclaringThreadPoolGroup(){
		return new ThreadPoolGroup();
	}


	/*
	 * 自定义RabbitMQ
	 * */
	@BeanDeclare(forClass = MyMQ.class, scope = BeanScope.GLOBAL)
	private MyMQ onDeclaringMyMQ() throws Exception {
		return new MyMQ();
	}
	/*
	 * 策略模式worker
	 * */
	@BeanDeclare(forClass = PolicyWorker.class, scope = BeanScope.GLOBAL)
	private PolicyWorker onDeclaringPolicyWorker() throws Exception {
		return new PolicyWorker();
	}
	/**
	 * Jedis 工具类
	 */
	@BeanDeclare(forClass = JedisUtil.class, scope = BeanScope.GLOBAL)
	private JedisUtil onDeclaringJedisUtil(){
		return new JedisUtil();
	}

	/*
	 * 消息工具远程服务
	 * */
	@BeanDeclare(forClass = IMessageToolRemoteService.class, scope = BeanScope.TEMPORY)
	private IMessageToolRemoteService onDeclaringMessageToolRemoteService(){
		return new MessageToolRemoteServiceImpl();
	}


}
